package org.example.demo;

import java.util.Random;

/*
*  随机抽奖,不重复.  2元,888元, 1000元
* 
* */
public class Test2 {
    public static void  main(String[] args){
        int[] arr =  { 2,888,100 };
        int[] indexArr = new int[arr.length];

        int  res1 =   getOne(arr,indexArr);
        int  res2 =   getOne(arr,indexArr);
        int  res3 =   getOne(arr,indexArr);
        System.out.println(res1);
        System.out.println(res2);
        System.out.println(res3);
    }
    public static int getOne(int[] arr ,int[] indexArr){
        int one = 0;

        while (indexArr[one] == 0){
            int random = new Random().nextInt(arr.length);
            if(indexArr[random] == 0){
                indexArr[random] = 1;
                one =   arr[random];
                break;
            }
        }
        return  one;
    }
}